/****************************************
Figure 1
*****************************************/

use "$dir/Data/Final/Isonymy_fs.dta", clear

collapse (mean) IsoNonrand_f = IsoNonrand_fs_noban  ///
	(rawsum) N_f = N_fs_noban [fw=N_fs_noban] , by(surname pre)

gen CM_f = max(IsoNonrand_f, 0) * 4
drop IsoNonrand_f

reshape wide CM_f N_f, i(surname) j(pre)

rename *1 *_pre
rename *0 *_post


gen N_f = N_f_pre + N_f_post
drop if N_f_pre == 0 | N_f_post == 0
drop if N_f == .

binscatter  CM_f_post CM_f_pre [fw=N_f] if N_f_post >= 50 & N_f_pre >= 50, nq(30) ///
	xtitle("Cousin marriage rate (1750-1858)") ///
	ytitle("Cousin marriage rate (1859-1940)")

graph export "$dir/Output/TablesFigures/Persistence_CM_prepost_exclbanyrs.png", replace
